using Common.Commands;
using Common.Commands.LeadCommands;
using Core.Domain.Model;
using Dto.ApiResponses.LeadResponses;
using Sanelib.DataOperation;

namespace Core.Processors.LeadsProcessors
{
	public class AddLeadsProcessor : ICommandProcessor<AddLead>
	{
		private readonly IRepository<Lead> _leadsRepository;

		public AddLeadsProcessor(IRepository<Lead> leadsRepository)
		{
			_leadsRepository = leadsRepository;
		}

		public dynamic Process(AddLead command)
 		{		
			var leads = new Lead
			{ 
				Id = command.Id,
				Name = command.Name,
				CompanyName = command.CompanyName,
				Email = command.Email,
				Phone = command.Phone,
				Description = command.Description,
                CreatedBy = command.UserId,
                ImageData = command.ImageData
			}; 
			_leadsRepository.Add(leads);


            var response = new LeadResponse
            {
              Id  = command.Id,
              Name = command.Name,
              CompanyName = command.CompanyName,
              Email = command.Email,
              Phone = command.Phone,
              Description = command.Description,
              CreatedBy = command.UserId              
            };

			return response;
		}       
	}
}
